﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Threading;

namespace FeatureDetection {
    public class Drawer {
        protected DrawingGroup drawingGroup { get; set; }
        protected Thread thread { get; set; }
        protected ThreadStart func { get; set; }


        public Drawer(DrawingGroup _drawingGroup, ThreadStart _func) {
            this.drawingGroup = _drawingGroup;
            this.func = _func;
        }
        public void Invalidate() {
            if(thread == null)  thread = new Thread(func);
            switch(thread.ThreadState) {
                case ThreadState.Unstarted:
                    thread.Start();
                    break;
                case ThreadState.Stopped:
                    thread.Join();
                    thread = new Thread(func);
                    thread.Start();
                    break;
                default:
                    return;
            }
        }
    }
}
